package com.xiaoxing.zhinenghuacangku.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Button;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.xiaoxing.zhinenghuacangku.R;
import com.xiaoxing.zhinenghuacangku.R2;
import com.xiaoxing.zhinenghuacangku.di.component.DaggerMenuSelectionComponent;
import com.xiaoxing.zhinenghuacangku.di.module.MenuSelectionModule;
import com.xiaoxing.zhinenghuacangku.mvp.contract.MenuSelectionContract;
import com.xiaoxing.zhinenghuacangku.mvp.presenter.MenuSelectionPresenter;

import butterknife.BindView;
import butterknife.OnClick;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.commonsdk.utils.Utils;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;

import static com.jess.arms.base.BaseConstants.HTTP_URL;
import static com.jess.arms.utils.Preconditions.checkNotNull;


@Route(path = RouterHub.ZHI_NENG_HUA_CANG_KU_MENU_SELECTION_ACTIVITY)
public class MenuSelectionActivity extends BaseActivity
        <MenuSelectionPresenter> implements MenuSelectionContract.View {


    @BindView(R2.id.btn_ru_ku)
    Button btnRuKu;
    @BindView(R2.id.btn_chu_ku)
    Button btnChuKu;
    @BindView(R2.id.btn_tui_ku)
    Button btnTuiKu;


    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerMenuSelectionComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .menuSelectionModule(new MenuSelectionModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.zhi_neng_cang_ku_activity_menu_selection; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        String httpUrl = mSharedPreferencesHelper.getString(HTTP_URL);
        httpUrl = httpUrl.replace(" ", "");
        RetrofitUrlManager.getInstance().setGlobalDomain(httpUrl);
//        ToolbarUtils.initToolbarTitleBack(this, "default_title");

    }


    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }


    @OnClick(R2.id.btn_ru_ku)
    public void onBtnRuKuClicked() {
        Bundle bundle = new Bundle();
        bundle.putString("type", "ruku");
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_STORAGE_ACTIVITY, bundle);
    }

    @OnClick(R2.id.btn_zhi_jian_wan_cheng_ru_ku)
    public void onBtnRuKu_ZhiJianWanChengRuKuClicked() {
        Bundle bundle = new Bundle();
        bundle.putString("type", "ruku_zhijianwancheng");
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_STORAGE_ACTIVITY, bundle);
    }


    @OnClick(R2.id.btn_chu_ku)
    public void onBtnChuKuClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_OUT_OF_THE_LIBRARY_ACTIVITY);
    }

    @OnClick(R2.id.btn_tui_ku)
    public void onBtnTuiKuClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_RETURN_LIBRARY_MENU_ACTIVITY);
    }

    @OnClick(R2.id.btn_yi_ku)
    public void onBtnYiKuClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_YI_KU);
    }

    @OnClick(R2.id.btn_ru_ku_qing_zhang)
    public void onBtnRuKuQingZhangClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_ACTIVITY_RU_KU_QING_ZHANG);
    }

    @OnClick(R2.id.btn_huan_chong_wei_zhi_kong)
    public void onBtnHuanChongWeiZhiZhiKongClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_ACTIVITY_ZHI_KONG_HUAN_CHONG_WEI);
    }

    @OnClick(R2.id.btn_yi_ku_qing_zhang)
    public void onBtnYiKuQingZhangClicked() {
        Utils.navigation(MenuSelectionActivity.this, RouterHub.ZHI_NENG_HUA_CANG_KU_ACTIVITY_YI_KU_QING_ZHANG);
    }

    @OnClick(R2.id.btn_chou_jian_chu_ku)
    public void chouJianChuKu() {
        Utils.navigation(this, RouterHub.ZHI_NENG_HUA_CANG_KU_ZHI_JIAN_ACTIVITY_CHOU_JIAN_CHU_KU_LIE_BIAO);
    }

    @OnClick(R2.id.btn_chou_jian_tui_ku)
    public void btnChouJianTuiKu() {
        Utils.navigation(this, RouterHub.ZHI_NENG_HUA_CANG_KU_ZHI_JIAN_ACTIVITY_CHOU_JIAN_TUI_KU_LIE_BIAO);
    }

}
